﻿<html DIR="LTR" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ddue="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
  <head>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=utf-8" />
    <META NAME="save" CONTENT="history" />
    <title>Readme_Sales Orders Mobile Replication Sample</title>
    
    
    
    <style TYPE="text/css">
body
{
background: #FFFFFF;
color: #000000;
font-family:    Verdana;
font-size: medium;
font-style: normal;
font-weight: normal;
margin-top: 0;
margin-bottom:  0;
margin-left:    0;
margin-right:   0;
width:  100%;
}

div.#mainSection
{
font-size: 70%;
width: 100%;
padding-left:    10;
margin-right: 10;
}

div.#mainBody
{
font-size: 90%;
margin-top: 10;
padding-bottom: 20;
}

div.#header
{
background-color: #D2D2D2;
padding-top:    0;
padding-bottom: 0;
padding-left:   10;
padding-right:  0;
width:          100%;
}

div.#header table
{
border-bottom-color: #C8CDDE;
border-bottom-style: solid;
border-bottom-width: 1;
width:  100%;
}

span.#runningHeaderText
{
color: #003399;
font-size: 90%;
}

span.#nsrTitle
{
/*    color: #003399;*/
font-size: 120%;
font-weight: 600;
}

div.#header table td
{
color: #000000;
font-size: 70%;
margin-top: 0;
margin-bottom:  0;
padding-right: 20;
}

div.#header table tr.#headerTableRow3 td
{
padding-bottom: 2;
padding-top: 5;
}

div.#header table.#bottomTable
{
border-top-color: #FFFFFF;
border-top-style: solid;
border-top-width: 1;
text-align: left;
}

div.#footer
{
font-size: 90%;
margin-top: 0;
margin-bottom:  0;
margin-left:    -5;
margin-right:   0;
padding-top:    2;
padding-bottom: 2;
padding-left:   0;
padding-right:  0;
width:  100%;
}

hr.#footerHR
{
border-bottom-color: #EEEEFF;
border-bottom-style: solid;
border-bottom-width: 1;
border-top-color: C8CDDE;
border-top-style: solid;
border-top-width: 1;
height: 3;
color: #D2D2D2;
}

div.section
{
padding-top:    2;
padding-bottom: 2;
padding-right:  15;
width:  100%;
}

.heading
{
color:          #000000;
font-weight:    bold;
margin-top:     18;
margin-bottom:  8;
}

h1.heading
{
color: #000000;
font-size:  150%;
}

.subHeading
{
color:          #000000;
font-weight:    bold;
font-size:      150%;
margin-bottom:  4;
}

h2.subHeading
{
color:          #000000;
font-weight:    bold;
font-size:      130%;
}
h3.subHeading
{
color:  #000000;
font-size: 125%;
font-weight: bold;
}

h4.subHeading
{
color: #000000;
font-size: 110%;
font-weight: bold;
}

h4.procedureHeading
{
color: #000080;
font-size: 110%;
font-weight: bold;
}

h5.subHeading
{
color: #000000;
font-size: 100%;
font-weight: bold;
}

img
{
padding-bottom: 10;
}

img.toggle
{
border: 0;
margin-right: 5;
padding-bottom: 10;
}

img.copyCodeImage
{
border: 0;
margin: 1;
margin-right: 3;
padding-bottom: 10;
}

img.downloadCodeImage
{
border: 0;
margin-right: 3;
padding-bottom: 10;
}

img.viewCodeImage
{
border: 0;
margin-right: 3;
padding-bottom: 10;
}

img.note
{
border: 0;
margin-right: 3;
padding-bottom: 10;
}

img.#membersOptionsFilterImage
{
border: 0;
margin-left: 10;
vertical-align: middle;
padding-bottom: 10;
}

img.#toggleAllImage
{
margin-left: 4;
vertical-align: middle;
padding-bottom: 10;
}

div.#mainSection table
{
border: 0;
font-size: 100%;
width:  100%;
margin-top: 5px;
margin-bottom: 15px;
}

div.#mainSection table tr
{
vertical-align: top;
}

div.#mainSection table th
{
text-align: left;
background: #D8D8D8;
border-bottom-color: #D8D8D8;
border-bottom-style: solid;
border-bottom-width: 1;
color: #000000;
padding-left: 5;
padding-right: 5;
}

div.#mainSection table td
{
background: #F2F2F2;
border-top-color: #D8D8D8;
border-top-style: solid;
border-top-width: 1;
padding-left: 5;
padding-right: 5;
}

div.#mainSection table td.imageCell
{
white-space: nowrap;
}

div.code
{
width: 98%;
}

div.code table
{
border: 0;
font-size: 95%;
margin-bottom: 5;
width: 100%
}

div.code table th
{
text-align: left;
background: #D8D8D8;
border-bottom-color: #D8D8D8;
border-bottom-style: solid;
border-bottom-width: 1;
color: #000000;
font-weight: bold;
padding-left: 5;
padding-right: 5;
}

div.code table td
{
background: #CCCCCC;
border-top-color: #D8D8D8;
border-top-style: solid;
border-top-width: 1;
padding-left: 5;
padding-right: 5;
padding-top: 5;
}

div.alert
{
margin-left: 10;
width: 98%;
}

div.alert table
{
border: 1;
font-size: 100%;
width:  100%;
border: solid 1 #DEDFEF;
}

div.alert table th
{
text-align: left;
background: #D8D8D8;
border-bottom-width: 0;
color: #000000;
padding-left: 5;
padding-right: 5;
border: solid 1 #DEDFEF;
}

div.alert table td
{
background: #FFFFFF;
border-top-color: #D8D8D8;
border-top-style: solid;
border-top-width: 1;
padding-left: 5;
padding-right: 5;
border: solid 1 #DEDFEF;
}

span.copyCode
{
color: #0000ff;
font-size: 90%;
font-weight: normal;
cursor: hand;
float: right;
display: inline;
text-align: right;
}

.downloadCode
{
color: #0000ff;
font-size: 90%;
font-weight: normal;
cursor: hand;
}

.viewCode
{
color: #0000ff;
font-size: 90%;
font-weight: normal;
cursor: hand;
}

div.code pre
{
font-family:    Monospace, Courier New, Courier;
font-size: 105%;
color:  #000000;
}

code
{
font-family:    Monospace, Courier New, Courier;
font-size: 105%;
color:  #000000;
}

dl
{
margin-top: 0;
padding-left:   1;
}

dd
{
margin-bottom:  0;
margin-left:    0;
padding-left:   20;
}

dd p
{
margin-top: 5;
}

ul
{
margin-left: 17;
list-style-type: disc;
}

ul ul
{
margin-bottom: 4;
margin-left: 17;
margin-top: 3;
list-style-type: disc;
}

ol
{
margin-left: 24;
list-style-type: decimal;
}

ol ol
{
margin-left: 24;
margin-top: 3;
list-style-type: lower-alpha;
}

li
{
margin-top: 0;
margin-bottom: 0;
padding-bottom: 0;
padding-top: 0;
margin-left: 5;
}

p
{
margin-bottom: 15;
}

.tip
{
color:  #0000FF;
font-style: italic;
cursor:hand;
text-decoration:underline;
}

.math
{
font-family: Times New Roman;
font-size: 125%
}
.sourceCodeList
{
font-family: Verdana;
font-size: 90%;
}

pre.viewCode
{
width: 100%;
overflow: auto;
}

li:hover table, li.over table
{
background-color: #C0C0C0;
}

li:hover ul, li.over ul
{
background-color: #d2d2d2;
border: 1px solid #000;
display: block;
}
            </style>
  </head>
  <body>
    <!--Topic built:02/12/2008 21:30:29-->

    
    
    
    
    
    
    
    
    
    <div id="header">
      <table width="100%" id="topTable"><tr>
          <td align="left">
            <span id="nsrTitle">Readme_Sales Orders Mobile Replication Sample</span>
          </td>
          <td align="right">
            <span id="headfb" class="feedbackhead">
            </span>
          </td>
        </tr></table>
      
      
      
    </div>
    <div id="mainSection">
      <div id="mainBody"><p> 2/12/2008 9:30:29 PM</p>
        
        <font color="DarkGray">[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.] </font><p /> 
        <span id="changeHistory">
        </span>
    <p>
      This sample works only with SQL Server 2005 and SQL Server 2008. It will not work with any version of SQL Server earlier than SQL Server 2005. This sample is the SQL Server Compact 3.5 SP1 Subscriber version of the <a href="html/4ee7581f-9b6e-4a06-8acf-02318af4afa5.htm">Sales Orders Sample for Merge Replication</a>. This sample highlights using Microsoft SQL Server Compact 3.5 SP1 as a Subscriber in a merge replication topology for delivering data to mobile users. It also demonstrates the programmability features of replication in SQL Server Compact 3.5 SP1. The sample is a Windows Forms-based application that uses standard Microsoft data access technologies and merge replication to enable a salesperson to maintain her own local data while synchronizing periodically with the home office. The publication used by this sample is created when you install the <a href="html/4ee7581f-9b6e-4a06-8acf-02318af4afa5.htm">Sales Orders Sample for Merge Replication</a>. For more information about the replication scenario used in this sample, see <b>Sales Orders Sample Scenario</b>.</p>
  <h1 class="heading">Languages</h1><div id="sectionSection0" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <ul xmlns=""><li>
          C#<br />
        </li></ul>
    </content></div><h1 class="heading">Prerequisites</h1><div id="sectionSection1" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">Before running this sample, make sure the following software is installed on the development computer:</p>
      <ul xmlns=""><li>
          
            Microsoft Compact 2.0.<br />
        </li><li>
          
            .NET Framework SDK 2.0 or Microsoft Visual Studio 2005. For more information, see <b>Installing the .NET Framework SDK</b>.<br />
        </li><li>
          
            Microsoft SQL Server Compact 3.5 SP1.<br />
        </li><li>
          
            Microsoft ActiveSync 4.0 or later versions.<br />
        </li><li>
          The SQL Server samples. These samples are available on the <b>Microsoft SQL Server Samples and Community Projects</b> page on <a href="http://go.microsoft.com/fwlink/?linkid=62796" alt=""><linkText xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">CodePlex</linkText></a>. For more information, see <a href="html/e8117979-fe03-441e-be85-894fa616227a.htm">Considerations for Installing SQL Server Samples and Sample Databases</a>.<br />
        </li></ul>
      <p xmlns="">You must also have either a mobile device or a mobile device emulator (included with Microsoft Visual Studio 2005) with at least 15 MB of free memory on which to deploy and run the sample.</p>
      <p xmlns="">To initialize the subscription and download sales order data to the device, you must have a SQL Server Publisher configured to run the <a href="html/4ee7581f-9b6e-4a06-8acf-02318af4afa5.htm">Sales Orders Sample for Merge Replication</a>.</p>
    </content></div><h1 class="heading">Required Permissions</h1><div id="sectionSection2" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">The permissions required to configure and run the Sales Orders sample are based on replication security requirements, and are as follows:</p>
      <ul xmlns=""><li>
          To run InstallSalesOrdersSample.bat at the Publisher, your Windows account must be a member of the <b>sysadmin</b> fixed server role at the Publisher. This batch file configures replication, creates the AdvWorksSalesOrders publication, and generates the initial snapshot.<br />
        </li><li>
          To initialize the subscription and synchronize data with the Publisher, the Windows account used to connect to the Web server must meet the following requirements:<br />
          <ul><li>
              Have a valid login at the Publisher associated with a user in the publication database.<br />
            </li><li>
              Have a valid login at the Distributor associated with a user in the distribution database (or the guest user).<br />
            </li><li>
              Be a member of the publication access list (PAL) for the AdvWorksSalesOrders publication. <br />
            </li></ul>
          <div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Note: </th></tr><tr><td>
            When you use an anonymous connection to the Web server, the IIS anonymous Windows account is used to connect to the Publisher.<p />
          </td></tr></table><p /></div>
        </li><li>
          To connect to the Web server using Secure Sockets Layer (SSL) encryption, you must have a copy of the root certificate of the server certificate used to secure the Web server installed as a root certificate on the device. If the Web server is configured to require client certificates, you must also have a valid certificate installed as a personal certificate on the device.<br />
        </li></ul>
    </content></div><h1 class="heading">Building and Configuring the Sample</h1><div id="sectionSection3" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">To configure the replication topology and build and deploy the sample project:</p>
      <ol xmlns=""><li>
          At the Publisher, run the publication installation script from the Sales Orders sample.<br />
        </li><li>
          Build the Sales Orders sample and deploy the business logic handler assembly on the Web server.<br />
        </li><li>
          Run the Configure Web Synchronization wizard to configure the virtual directory. <br />
        </li><li>
          Build and deploy the sample to a device or device emulator using Visual Studio 2005.<br />
        </li></ol>
      <h4 class="procedureHeading" xmlns="">To configure the Publisher, and build and deploy the sample project</h4><div id="procedureSectionEBBFBHA" class="section" xmlns=""><ol><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">On a computer that is running SQL Server 2005 or a later version, execute the installation script from the <a href="html/4ee7581f-9b6e-4a06-8acf-02318af4afa5.htm">Sales Orders Sample for Merge Replication</a> to create the AdvWorksSalesOrders publication at the Publisher.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">At the command prompt, navigate to the SQL Server samples installation directory. The default is C:\Program Files\Microsoft SQL Server\100\Samples\. </p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Execute the following at a .NET Framework or Microsoft Visual Studio 2005 command prompt:</p>
              <p xmlns="">
                <code>sn -k SampleKey.snk</code>
              </p>
              <div class="alert" xmlns=""><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Note: </th></tr><tr><td>
                You can skip this step if this key was previously created for use with another sample. <p />
              </td></tr></table><p /></div>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Navigate to the installation location for the Sales Orders sample solution in Microsoft Visual C#. The default is C:\Program Files\Microsoft SQL Server\100\Samples\Replication\Merge\SalesOrders\CS.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Open the SalesOrders.sln solution file in Visual Studio 2005.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Build the project. </p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Place a copy of the BusinessLogic.dll assembly in the C:\Program Files\Microsoft SQL Server\100\COM directory on the Web server. </p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Run the Configure Web synchronization Wizard to create a virtual directory name "SalesOrdersMobile." For information about how to run this wizard, follow the steps in the <b>How To: Configure Connectivity with the Configure Web Synchronization Wizard</b> topic in SQL Server Compact 3.5 SP1 Books Online.</p>
              <div class="alert" xmlns=""><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Note: </th></tr><tr><td>
                When client certificates are required to connect to the Web server, you must have a valid personal certificate installed on the device.<p />
              </td></tr></table><p /></div>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">If using an anonymous connection to the Web server, create a login at the Publisher for the Windows account used for anonymous access, create a user in the <b>AdventureWorks</b> database for this login, and add this user to the PAL for the AdvWorksSalesOrders publication. For more information, see <b>How to: Manage Logins in the Publication Access List (SQL Server Management Studio)</b>. </p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Navigate to the installation location for the Sales Orders Mobile sample solution in Microsoft Visual C#. The default is C:\Program Files\Microsoft SQL Server\100\Samples\Replication\Merge\SalesOrdersMobile\CS.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Open the SalesOrdersMobile.sln solution file in Visual Studio 2005.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Connect the device or device emulator and start ActiveSync.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Build and deploy the project to the device. </p>
            </content>
          </li></ol></div>
    </content></div><h1 class="heading">Running the Sample</h1><div id="sectionSection4" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <h4 class="procedureHeading" xmlns="">To run the Sales Orders Mobile sample and synchronize data</h4><div id="procedureSectionEDBDBHA" class="section" xmlns=""><ol><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Cradle the device and ensure that ActiveSync is running.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">To secure the connection to the Web server using SSL, export the root certificate of the server certificate used to secure the SalesOrdersMobile virtual directory (in DER encoded binary X.509 format), copy it to the device, and tap to install it as a root certificate on the device. When client certificates are required to connect to the Web server, you must also have a valid personal certificate installed on the device. </p>
              <div class="alert" xmlns=""><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Security Note: </th></tr><tr><td>
                If you use Basic Authentication to connect to the Web server, you should use SSL to encrypt the connection to the Web server. This protects the Windows credentials.<p />
              </td></tr></table><p /></div>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">On the device, start Internet Explorer and browse to one of the following URLs:</p>
              <ul xmlns=""><li>
                  http://<i>webserver</i>/SalesOrdersMobile/sqlcesa30.dll?diag - when using anonymous access to the Web server.<br />
                </li><li>
                  https://<i>webserver</i>/SalesOrdersMobile/sqlcesa30.dll?diag - when connecting to the Web server using SSL and specifying a Windows login and password to use for Basic Authentication.<br />
                </li></ul>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">On the device or device emulator, start the SalesOrdersMobile program. When run for the first time, the program creates the mobile subscription database (\My Documents\AWMobile.sdf).</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">On the <b>Settings</b> page, enter the name of the Publisher and the URL of the Web server in one of the following formats:</p>
              <ul xmlns=""><li>
                  http://<i>webserver</i>/SalesOrdersMobile/sqlcesa30.dll. This URL is used when the <b>Connect anonymously to server</b> box is checked. <br />
                </li><li>
                  https://<i>webserver</i>/SalesOrdersMobile/sqlcesa30.dll. This URL is used when the <b>Connect anonymously to server</b> box is unchecked. You must also specify a Windows login and password in the <b>Windows login</b> and <b>Password</b> fields, where these values are the credentials that correspond to a Windows login at the Publisher and Distributor. <br />
                </li></ul>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Tap <b>Save</b> to save these settings.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">On the <b>Synchronize</b> page, verify the value in the <b>Hostname</b> field, select <b>Full (recommended)</b> for <b>Sync type</b>, and then tap <b>Synchronize</b>. The device connects to the specified Web server to create, initialize, and download subscription data for the application.</p>
            </content>
          </li></ol></div>
      <h4 class="procedureHeading" xmlns="">To update sales order data and synchronize with the Publisher</h4><div id="procedureSectionEBBDBHA" class="section" xmlns=""><ol><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">With the subscription initialized, on the <b>File</b> menu, tap <b>View Orders</b>, and select a customer from the <b>Customers</b> list.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">To update an existing order, tap on an existing order in the <b>Orders</b> table, then do one of the following:</p>
              <ul xmlns=""><li>
                  To update an existing item, double-tap an item in the <b>Order Items</b> grid, change the <b>Quantity</b> value for the selected item, and then tap <b>Save</b>.<br />
                </li><li>
                  To add a new item to the order, tap <b>Add New</b>, select the product from the <b>Category</b> and <b>Product</b> lists, set the order quantity in the <b>Quantity</b> field, and then tap <b>Save</b>.<br />
                </li><li>
                  To delete an existing item from an order, select the item in the <b>Order Items</b> grid, and then tap <b>Delete</b>.<br />
                </li></ul>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Tap <b>Synchronize</b> from the <b>Tools</b> menu, select either <b>Full (recommended)</b> or <b>Upload only</b> from the <b>Sync type</b> list, and then tap <b>Synchronize</b>.</p>
            </content>
          </li></ol></div>
    </content></div><!--[if gte IE 5]>
			<tool:tip element="seeAlsoToolTip" avoidmouse="false"/><tool:tip element="languageFilterToolTip" avoidmouse="false"/><tool:tip element="roleInfoSpan" avoidmouse="false"/>
		<![endif]--></div>
      <div id="footer">
			
			© 2008 Microsoft Corporation. All rights reserved.
		</div>
    </div>
  </body>
</html>